package com.xiaohu.myspace.buiness.buinessinterfaceimple;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.xiaohu.myspace.buiness.BaseBuiness;
import com.xiaohu.myspace.buiness.buinessinterface.OptionInfoInterface;
import com.xiaohu.myspace.database.dao.OptionInfoDao;
import com.xiaohu.myspace.database.entity.OptionInfo;

public class OptionInfoInterfaceImple extends BaseBuiness implements
		OptionInfoInterface {
	
	private OptionInfoDao optionInfoDao;

	public OptionInfoDao getOptionInfoDao() {
		return optionInfoDao;
	}

	public void setOptionInfoDao(OptionInfoDao optionInfoDao) {
		this.optionInfoDao = optionInfoDao;
	}

	@Override
	public boolean addOptionInfo(final OptionInfo optionInfo) {
		return doSomeThingInDB(new DoInBuiness<Boolean>() {

			@Override
			public Boolean doSomeThingInBuiness(SessionFactory sessionFactory,
					Session session) {
				return optionInfoDao.addOptionInfo(optionInfo, session);
			}
			
		});
	}

	@Override
	public boolean deleteOptionInfo(final OptionInfo optionInfo) {
		return doSomeThingInDB(new DoInBuiness<Boolean>() {

			@Override
			public Boolean doSomeThingInBuiness(SessionFactory sessionFactory,
					Session session) {
				return optionInfoDao.deleteOptionInfo(optionInfo, session);
			}
			
		});
	}

	@Override
	public boolean updateOptionInfo(final OptionInfo optionInfo) {
		return doSomeThingInDB(new DoInBuiness<Boolean>() {

			@Override
			public Boolean doSomeThingInBuiness(SessionFactory sessionFactory,
					Session session) {
				return optionInfoDao.updateOptionInfo(optionInfo, session);
			}
			
		});
	}

	@Override
	public List<OptionInfo> selectOptionInfoWithOptionCode(final int optionCode) {
		return doSomeThingInDB(new DoInBuiness<List<OptionInfo>>() {

			@Override
			public List<OptionInfo> doSomeThingInBuiness(SessionFactory sessionFactory,
					Session session) {
				return optionInfoDao.selectOptionInfoWithOptionCode(optionCode, session);
			}
			
		});
	}

}
